//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    public class PageMargins : IOfficeXmlSerializable
    {
        private double b;
        private double footer;
        private double header;
        private double l;

        private double r;

        private double t;

        public double Left
        {
            get { return l; }
            set { l = value; }
        }

        public double Right
        {
            get { return r; }
            set { r = value; }
        }

        public double Top
        {
            get { return t; }
            set { t = value; }
        }

        public double Bottom
        {
            get { return b; }
            set { b = value; }
        }

        public double Header
        {
            get { return header; }
            set { header = value; }
        }

        public double Footer
        {
            get { return footer; }
            set { footer = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read("pageMargins"))
            {
                l = c.GetDouble("l");
                r = c.GetDouble("r");
                t = c.GetDouble("t");
                b = c.GetDouble("b");
                header = c.GetDouble("header");
                footer = c.GetDouble("footer");
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("pageMargins"))
            {
                c.SetDouble("l", l);
                c.SetDouble("r", r);
                c.SetDouble("t", t);
                c.SetDouble("b", b);
                c.SetDouble("header", header);
                c.SetDouble("footer", footer);
            }
        }

        #endregion
    }
}